﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HDSmartCommunity.BUS;
using HDSmartCommunity.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HDSmartCommunity.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class DownLoadController : ControllerBase
    {
        public DownLoadController()
        {
        }

        [HttpPost]
        [HttpGet]
        [Route("DownLoadLog")]
        public ResponseMessage DownLoadLog()
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                LogBUS logBUS = new LogBUS();
                message.data = logBUS.DownLoad();
            }
            catch (Exception ex)
            {
                message.errcode = 1;
                message.errmsg = "失败";
            }

            return message;
        }

        [HttpPost]
        [HttpGet]
        [Route("DownLoadNetWorkLog")]
        public ResponseMessage DownLoadNetWorkLog()
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                LogBUS logBUS = new LogBUS();
                message.data = logBUS.NetworkDownLoad();
            }
            catch (Exception ex)
            {
                message.errcode = 1;
                message.errmsg = "失败";
            }

            return message;
        }

        [HttpPost]
        [HttpGet]
        [Route("SerialDownLoadLog")]
        public ResponseMessage SerialDownLoadLog()
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                LogBUS logBUS = new LogBUS();
                message.data = logBUS.SerialDownLoad();
            }
            catch (Exception ex)
            {
                message.errcode = 1;
                message.errmsg = "失败";
            }

            return message;
        }
    }
}
